package com.ants.dgsxpt.app;

import com.ants.platform.core.bean.Page;
import com.ants.platform.core.service.RequestLogService;
import com.ants.platform.core.utils.ResponseUtil;
import com.ants.platform.weixin.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by liushun on 2016/8/12.
 */
@RestController
public class UserApi {

    @Autowired
    private TestService testService;

    @Autowired
    private RequestLogService logService;

    @RequestMapping(value = "/user/list", method = RequestMethod.GET)
    public Object getUsers(@RequestParam Integer page
            , @RequestParam Integer rows
            , String orderField
            , String orderDirection) {
        long startTime = System.currentTimeMillis();
        Page p = testService.getList(page, rows, orderField, orderDirection);
        return ResponseUtil.easyuiResponse(p.getData(), p.getTotalCount());
    }

    @RequestMapping(value = "/requestlogs/list", method = RequestMethod.GET)
    public Object getRequestLogs(@RequestParam Integer page
            , @RequestParam Integer rows
            , String orderField
            , String orderDirection) {
        long startTime = System.currentTimeMillis();
        Page p = logService.getList(page, rows, orderField, orderDirection);
        return ResponseUtil.easyuiResponse(p.getData(), p.getTotalCount());
    }
}
